package com.mccken.springframework.context.support;

import com.mccken.springframework.beans.factory.ConfigurableListableBeanFactory;
import com.mccken.springframework.beans.factory.support.DefaultListableBeanFactory;

/**
 * @program: mccken-collect
 * @description:
 * @author: mccken
 * @create: 2022-12-02 10:39
 **/
public abstract class AbstractRefreshableApplicationContext extends AbstractApplicationContext {
	
	private DefaultListableBeanFactory beanFactory;
	
	@Override
	protected void refreshBeanFactory() {
		DefaultListableBeanFactory beanFactory = createBeanFactory();
		loadBeanDefinitions(beanFactory);
		this.beanFactory = beanFactory;
	}

	protected abstract void loadBeanDefinitions(DefaultListableBeanFactory beanFactory);

	private DefaultListableBeanFactory createBeanFactory() {
		return new DefaultListableBeanFactory();
	}

	@Override
	protected ConfigurableListableBeanFactory getBeanFactory() {
		return beanFactory;
	}
}
